package it.avantsoft.ls.gl.message;

import java.io.DataOutputStream;
import java.io.IOException;

public class NewChildMessage extends GroupLeaderMessage {
    private String newChildId;
    private int port;

    public NewChildMessage(DataOutputStream out, String newChildI, int port) {
        super(out);
        this.newChildId = newChildI;
        this.port = port;
    }

    public boolean send() {
        boolean sent = false;
        try {
            writeByte(NEW_CHILD);
            writeUTF(newChildId);
            writeInt(port);
            flush();
            sent = true;
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        return sent;
    }

    public String toString() {
        return "NewChildMessage{" +
                "childId='" + newChildId + '\'' +
                '}';
    }
}
